<!--
//依赖于jyy.common.js
function events(element){
	if(typeof element=="string"||element instanceof String){
		element = $(element);
	}
	if(element==null){
		return null;
	}
	eventsMap = new Map();
	this.addEvent = function(eventName, fun){
		try{
			eventName = eventName.toLowerCase();
			if(/^(on).*/.test(eventName)){
				eventName = eventName.substring(2);
			}
			if(eventName=="load"
				||eventName=="click"
				||eventName=="dbclick"
				||eventName=="focus"
				||eventName=="keypress"
				||eventName=="keyup"
				||eventName=="mousedown"
				||eventName=="mousemove"
				||eventName=="mouseout"
				||eventName=="mouseover"
				||eventName=="mouseup"
				||eventName=="resize"
				||eventName=="scroll"){
				var evens = eventsMap.get(eventName);
				if(evens!=null){
					evens[evens.length] = fun;
				} else {
					evens = new Array();
					evens[0] = fun;
					eventsMap.put(eventName, evens);
				}
				return true;
			} else {
				return false;
			}
		} catch (e) {
			return false;
		}
	};
	this.enableEvent = function(eventName){
		eventName = eventName.toLowerCase();
		if(/^(on).*/.test(eventName)){
			eventName = eventName.substring(2);
		}
		var events = eventsMap.get(eventName);
		if(events!==null){
			switch(eventName){
				case "load":
					element.onload = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "click":
					element.onclick = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "dbclick":
					element.ondbclick = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "focus":
					element.onfocus = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "keypress":
					element.onkeypress = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "keyup":
					element.onkeyup = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "mousedown":
					element.onmousedown = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "mousemove":
					element.onmousemove = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "mouseout":
					element.onmouseout = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "mouseover":
					element.onmouseover = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "mouseup":
					element.onmouseup = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "resize":
					element.onresize = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
				case "scroll":
					element.onscroll = function(e){
						for(var i=0;i<events.length;i+=1){
							events[i](e);
						}
					};
					break;
			}
			return true;
		} else {
			return false;
		}
	}
	this.enableAll = function(){
		var events = eventsMap.get("load");
		if(events!=null){
			element.onload = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("click");
		if(events!=null){
			element.onclick = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("dbclick");
		if(events!=null){
			element.ondbclick = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("focus");
		if(events!=null){
			element.onfocus = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("keypress");
		if(events!=null){
			element.onkeypress = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("keyup");
		if(events!=null){
			element.onkeyup = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("mousedown");
		if(events!=null){
			element.onmousedown = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("mousemove");
		if(events!=null){
			element.onmousemove = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("mouseout");
		if(events!=null){
			element.onmouseout = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("mouseover");
		if(events!=null){
			element.onmouseover = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("mouseup");
		if(events!=null){
			element.onmouseup = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("resize");
		if(events!=null){
			element.onresize = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		events = eventsMap.get("scroll");
		if(events!=null){
			element.onscroll = function(e){
				for(var i=0;i<events.length;i+=1){
					events[i](e);
				}
			};
		}
		
	}
	this.disable = function(eventName){
		eventName = eventName.toLowerCase();
		if(/^(on).*/.test(eventName)){
			eventName = eventName.substring(2);
		}
		switch(eventName){
			case "load":
				element.onload = null;
				break;
			case "click":
				element.onclick = null;
				break;
			case "dbclick":
				element.ondbclick = null;
				break;
			case "focus":
				element.onfocus = null;
				break;
			case "keypress":
				element.onkeypress = null;
				break;
			case "keyup":
				element.onkeyup = null;
				break;
			case "mousedown":
				element.onmousedown = null;
				break;
			case "mousemove":
				element.onmousemove = null;
				break;
			case "mouseout":
				element.onmouseout = null;
				break;
			case "mouseover":
				element.onmouseover = null;
				break;
			case "mouseup":
				element.onmouseup = null;
				break;
			case "resize":
				element.onresize = null;
				break;
			case "scroll":
				element.onscroll = null;
				break;
		}
	}
	this.disableAll = function(){
		element.onload = null;
		element.onclick = null;
		element.ondbclick = null;
		element.onfocus = null;
		element.onkeypress = null;
		element.onkeyup = null;
		element.onmousedown = null;
		element.onmousemove = null;
		element.onmouseout = null;
		element.onmouseover = null;
		element.onmouseup = null;
		element.onresize = null;
		element.onscroll = null;
	}
	return this;
}
//-->